package com.future.hedongjun.mine.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.future.baselib.activity.BaseListActivity;
import com.future.hedongjun.common.MyApp;
import com.future.hedongjun.home.activity.ClassDetailActivity;
import com.future.hedongjun.home.adapter.TopicAdapter;
import com.future.hedongjun.home.bean.TopicBean;
import com.google.gson.reflect.TypeToken;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import java.util.TreeMap;

public class MyClassActivity extends BaseListActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTitle("我的课程");
    }

    @Override
    protected BaseQuickAdapter getAdapter() {
        return new TopicAdapter(initTestData());
    }

    private List<TopicBean> initTestData() {
        ArrayList<TopicBean> beans = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            TopicBean bean = new TopicBean();
            bean.setCourse_id("1");
            bean.setMain_img("http://seopic.699pic.com/photo/50025/2423.jpg_wh1200.jpg");
            bean.setCourse_name("专题标题1");
            bean.setPrice(100.00);
            beans.add(bean);
        }
        return null;
    }

    @Override
    protected Type getTypeToken() {
        return new TypeToken<List<TopicBean>>(){}.getType();
    }

    @Override
    protected TreeMap<String, String> getRequestParams() {
        TreeMap<String, String> params = new TreeMap<>();
        params.put("apiCode","_mybuyclass_002");
        params.put("userToken", MyApp.getInstance().getUserToken());
        return params;
    }


    @Override
    public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
        TopicBean item = ((TopicAdapter) adapter).getItem(position);
        Intent intent = new Intent(this, ClassDetailActivity.class);
        intent.putExtra("id",item.getCourse_id());
        startActivity(intent);
    }
}
